//
// Created by liushuai on 2021/1/16.
//

#include "bigNumAdd.h"
std::string bigNumAdd(std::string s, std::string t) {
    std::string min_str = s;
    std::string max_str = t;
    if(s.size()>t.size()){
        min_str = t;
        max_str = s;
    }
    int min_size = min_str.size();
    int max_size = max_str.size();
    int pre = 0;
    std::string result = "";
    char current;
    for(int i=0;i<min_size;i++){
        int value = max_str[max_size-1-i]+min_str[min_size-1-i]-'0'-'0'+pre;
        pre = value/10;
        current = value%10+'0';
        result += current;
    }

    for(int index = max_str.size()-min_size-1;index>=0;index--){
        int value = (max_str[index]-'0'+pre);
        pre = value/10;
        current = value%10+'0';
        result+=current;
    }
    if(pre == 1)
        result+=pre+'0';
    std::reverse(result.begin(),result.end());
    return result;

}
